<template>
	<view>
		<view class="bg-white padding">
			<uni-segmented-control :current="current" :values="items" @clickItem="onClickItem" styleType="button"
				class="bg-white " activeColor="#00ac04"></uni-segmented-control>
		</view>


		<view class="  padding-sm margin-top-sm">
			<view v-for="item in list" class="margin-bottom bg-white padding-sm radius">
				<view>
					<view style="display: flex;  justify-content: space-between;">
						<view class="font-title font-34rpx" @click="yuanzi(item.orgIds)">{{item.shopTitle}} <uni-icons
								type="right" size="18"></uni-icons>
						</view>
						<view class="font-content font-12">{{item.title}}</view>
					</view>
					<view style="display: flex;  justify-content: space-between;" class="margin-top-sm">
						<view class="font-content font-12">
							{{item.status==0?'未付款':item.status==1?'已预约':item.status==2?'已完成':item.status==3?'已取消':'未知'}}
						</view>
						<view class="font-content font-12">{{item.date}}</view>
					</view>
					<view style="display: flex;  justify-content: space-between;" class="margin-top-sm">
						<view class="font-content font-12">
							{{item.dingjinStatus==0?'未付押金':item.dingjinStatus==1?'已付押金':item.dingjinStatus==2?'已退款':item.dingjinStatus==3?'已退款':'未知'}}
						</view>
						<view class="font-content font-12">押金:{{item.dingjin/100}}</view>
					</view>
				</view>
				<view class=" margin-top-sm" style="display: flex;justify-content: space-between;">
					<view>
						<!-- <button v-if="item.status==0" plain size="mini" class="login-btn cu-btn block   bg-red "
							style="color: red;border-color:red " @click="orderCancel(item.id)">取消</button> -->
					</view>
					<view>
						<!-- <button size="mini" class="login-btn cu-btn block   bg-red " style="background-color: #00ac04;"
							@click="orderCancel(item.id)">联系商家</button> -->
						<!-- 	<button v-if="item.status==1" plain size="mini" class="login-btn cu-btn block   bg-red "
							style="color: red;border-color:red " @click="orderCancel(item.id)">取消</button> -->
					</view>


				</view>
			</view>
			<view v-if="list.length==0" class="juzhong">
				暂无数据
			</view>
		</view>
	</view>
</template>
<script>
	import storage from '@/utils/storage'
	import {
		getListByShop,
		refund,
		orderCancel
	} from "@/api/shop/userorder/ShopUserOrderManagementApi.js"
	export default {

		data() {
			return {
				items: ['全部', '待使用', '已使用', '退款/取消'],
				current: 0,
				list: [],
				queryForm: {
					pageNo: 1,
					pageSize: 10,
					uid_EQ: "",
					status_EQ: "",
					date_ORDER: "DESC",
				},
			};
		},
		onReachBottom() {
			this.queryForm.pageNo++
			this.listAdd()
		},
		onLoad(o) {

			this.current = parseInt(o.type)
			this.queryForm.uid_EQ = this.$store.state.user.user.id


			this.$forceUpdate()
			this.getList()
		},
		methods: {
			yuanzi(id) {
				uni.navigateTo({
					url: "/pages/common/yuanzixiangqing/yuanzixiangqing?id=" + id
				})
			},
			onClickItem(e) {
				if (this.current != e.currentIndex) {
					this.current = e.currentIndex;

					if (this.current == 0) {
						this.queryForm.status_EQ = null
					}
					if (this.current == 1) {
						this.queryForm.status_EQ = 1
					}
					if (this.current == 2) {
						this.queryForm.status_EQ = 2
					}
					if (this.current == 3) {
						this.queryForm.status_EQ = 3
					}
					if (this.current == 4) {
						this.queryForm.status_EQ = null
					}

					this.queryForm.pageNo = 1
					this.getList()

				}
			},
			async getList() {
				let {
					data
				} = await getListByShop(this.queryForm);
				this.list = data.rows
			},

			async listAdd() {
				let {
					data
				} = await getList(this.queryForm);
				for (let s of data.rows) {
					this.list.push(s)
				}
			},

			async orderCancel(id) {
				let _this = this
				uni.showModal({
					title: '取消确认',
					content: '取消前请与院子协商,是否继续取消？',
					success: async function(res) {
						if (res.confirm) {
							let {
								data,
								msg
							} = await orderCancel({
								id: id
							});

							uni.showModal({
								title: '成功',
								content: msg,
								showCancel: false
							})

							_this.getList()
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});




			}
		}
	};
</script>
<style>
	page {
		/* background-color: white; */
	}
</style>